package model23;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author ilongsay
 * @Date: Create in 2019/10/10 15:22
 * @Description: don't bb,show you code
 */
public class DisptcatcherServlet {

    private static List<AdaptHandler> adaptHandlers = new ArrayList<>();

    public DisptcatcherServlet() {
        adaptHandlers.add(new RestControllerHandler());
        adaptHandlers.add(new HttpControllerHandler());
        adaptHandlers.add(new SimpleControllerHandler());
    }

    public void doDispacther() {
        RestControllerHandler restControllerHandler = new RestControllerHandler();
    }

    /**
     * 获取controller参数
     * @param controller 传入的controller
     *
     * @return model23.AdaptHandler
     * @date 2019/10/10 15:27
     * @author ilongsay
     */
    public AdaptHandler getHandler(Controller controller) {
        for (AdaptHandler adaptHandler : adaptHandlers) {
            if (adaptHandler.support(controller)) {
                return adaptHandler;
            }
        }
        return null;
    }
}
